package com.lixx.usercenter.exception;

import com.lixx.usercenter.common.ErrorCode;

/**
 * 类名称：BusinessException
 * 描述：业务异常
 *
 * @author: Lixx
 * 创建时间: 2025/08/09
 */

public class BusinessException extends RuntimeException {
    /**
     * 法典
     */
    private final int code;
    /**
     * 描述
     */
    private final String description;

    public BusinessException(String message, int code, String description) {
        super(message);
        this.code = code;
        this.description = description;
    }

    public BusinessException(ErrorCode errorCode) {
        super(errorCode.getMessage());
        this.code = errorCode.getCode();
        this.description = errorCode.getDescription();
    }

    public BusinessException(ErrorCode errorCode, String description) {
        super(errorCode.getMessage());
        this.code = errorCode.getCode();
        this.description = description;
    }

    public int getCode() {
        return code;
    }

    public String getDescription() {
        return description;
    }
}
